// ----------------------------------
// RSDK Project: Sonic 2 - Boss Attack Plus
// Script Description: Reset
// Script Author: Tails LP
// ----------------------------------

//-------Aliases-------//

private alias object.value0 : object.timer
private alias object.value1 : object.fadeValue
private alias object.value2 : selection.current
private alias object.value3 : rect.xBound
private alias object.value4 : rect.yBound
private alias object.value5 : fade.out

// menu selections


//private alias 0 : 

// object states

private alias 0 : NONE
private alias 1 : STARTING_UP
private alias 2 : FADE_IN
private alias 3 : RESET_TIME
private alias 4 : FADE_OUT

// selections

// Game Modes


private alias saveRAM[494] : saved.bossGameMode //7B8 SData.bin
private alias saveRAM[495] : saved.bossType //7BC SData.bin
private alias saveRAM[496] : saved.BossMusic //7C0 SData.bin
private alias saveRAM[497] : saved.Character //7C4 SData.bin
private alias saveRAM[498] : saved.TimeLimit //7C8 SData.bin
private alias saveRAM[499] : saved.superMode //7CC SData.bin

//-------Function declarations-------//

//-------Static Values-------//

//-------Tables-------//




//-------Functions-------//



event ObjectMain
	switch object.state
	case NONE
		object.inkEffect = INK_ALPHA
		object.value3 = 0
		object.value4 = 0
		break
	case STARTING_UP
		object.state = FADE_IN
		break
	case FADE_IN
		if object.value3 < 128
			object.value3 += 6
		else
			object.value3 = 128
			object.state = RESET_TIME
		endif
		if object.value4 < 64
			object.value4 += 3
		else
			object.value4 = 64
		endif
		break
	case RESET_TIME
		if object.alpha < 255
			object.alpha += 6
		endif
		temp0 = inputPress.left
		temp0 |= inputPress.right
		if temp0 == 1
			if selection.current == 0
				selection.current = 1
			else
				selection.current = 0
			end if
		end if
		break
	case FADE_OUT
		object.inkEffect = INK_ALPHA
		if fade.out == 1
			if object.alpha > 0
				object.alpha -= 8
			else
				if object.value3 > 0
					object.value3 -= 6
				else
					object.value3 = 0
					object.state = NONE
					object[-1].state = 3
					selection.current = 0
					fade.out = 0
				endif
				if object.value4 > 0
					object.value4 -= 3
				else
					object.value4 = 0
				endif
			endif
		endif

		if selection.current == 0
			fade.out = 1
		else
			if arrayPos0 > 499
				saveRAM[arrayPos0] = 0
				if arrayPos0 >= 600
					WriteSaveRAM()
					arrayPos0 = 0
					fade.out = 1
					PlaySFX(SFXName[Spike], 0)	
				endif
				arrayPos0 ++
			endif
		endif
		break
	endswitch
if object.state ==RESET_TIME
	switch selection.current
	case 0
	case 1
		temp0 = inputPress.ButtonA
		temp0 |= inputPress.ButtonC
		temp0 |= inputPress.Start
		if temp0 == 1
			object.state = FADE_OUT
		endif
		arrayPos0 = 500
		break
	endswitch
endif
end event
event ObjectDraw
//----------------------RECTANGLE------------------------------------

	temp0 = object.value3
	temp0 /= 2
	flipSign(temp0)
	temp1 = object.value4
	temp1 /= 2
	flipSign(temp1)
	temp0 += screen.xcenter
	temp1 += screen.ycenter
	DrawRect(temp0, temp1, object.value3, object.value4, 0, 0, 96, 255)


if object.state == RESET_TIME
//----------------------Reset Time?----------------------------------

	temp1 = screen.ycenter
	temp1 -= 24
	DrawSpriteScreenFX(0, FX_INK, screen.xcenter, temp1)
	temp1 += 8
	DrawSpriteScreenFX(1, FX_INK, screen.xcenter, temp1)

//----------------------Yes? No?------------------------------------

	temp0 = screen.xcenter
	temp1 += 32
	if selection.current == 0
		DrawSpriteScreenFX(5, FX_INK, temp0, temp1)
		DrawSpriteScreenFX(2, FX_INK, temp0, temp1)
	else
		DrawSpriteScreenFX(4, FX_INK, temp0, temp1)
		DrawSpriteScreenFX(3, FX_INK, temp0, temp1)
	endif
endif
end event

event ObjectStartup
	ReadSaveRAM()

	LoadSpriteSheet("LevelSelect/Icons.gif")
	SpriteFrame(-40, -3, 80, 7, 282, 494) 		// 00 RESET YOUR
	SpriteFrame(-24, -3, 48, 7, 313, 486) 		// 01 TIMES?

	SpriteFrame(-40, -3, 24, 7, 297, 454) 		// 02 YES
	SpriteFrame(24, -3, 16, 7, 297, 462) 		// 03 NO
	SpriteFrame(-40, -3, 24, 7, 314, 462) 		// 04 YES yellow
	SpriteFrame(24, -3, 16, 7, 322, 454) 		// 05 NO yellow
end event

event RSDKDraw
    DrawSprite(0)
end event

event RSDKLoad
    LoadSpriteSheet("Global/Display.gif")
    SpriteFrame(-16, -16, 32, 32, 223, 172)
end event